home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / move32.com / TEST32.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-06-04  |  3.6 KB  |  116 lines

  1. Program Test__TT_32Bit;
  2. { This is a very simple program to demonstrate how to use the Move32 procs.
  3.   All this program does is allocate 2 16K blocks of Heap space (P1 & P2) and
  4.   initializes them to all 3's and 2's respectively.  After each array is
  5.   init'd the 1st 4000 bytes are moved to video page 0 (does work on mono.),
  6.   and displys a simple message indicating which is being displayed.
  7.  
  8.     You will also note that when we move data from P1^ & P2^, I'm using the
  9.   Turbo Move() procedure.  This was done because almost all video boards
  10.   in use are only 8-bit cards.  If you have a decent-resolution profiler,
  11.   you can test both 16 & 32-bit procedures against their 8-bit counterpart
  12.   on an 8-bit device and find that real time spent to Xfer the data takes
  13.   much longer in spite of the fact that there are more iterations with Move().
  14.   Oh, by the way, if you still got a CGA card, you're gonna se a snow storm!
  15.  
  16.     If the program exits with a beep and a non-zero exit-code, then you're in
  17.   a graphics mode, please change to a text mode (0..3, or 7) and the exit-code
  18.   is what the machine Bios thinks is the current video mode is.
  19. }
  20. { 03 June, 1989   Written by: Thomas A. Toth, Jr.
  21.   Copyright(c) 1989  Synergy Software Developers
  22.      Please see documentation in TT_32Bit.pas
  23. }
  24.  
  25. USES
  26.   Crt,
  27.   TT_32Bit;
  28.  
  29. TYPE
  30.   BoolText = Array[Boolean] of String[7];
  31.  
  32. CONST
  33.   NumLoops   = 1;      { Used in a loop using Move32(), I left it there so
  34.                          you could easily add some code to test things like
  35.                          timing comparisons, etc. }
  36.  
  37.   XFerMethod : BoolText = ('16-Bit','32-bit');
  38.  
  39.  
  40. VAR
  41.   P1,
  42.   P2       : Pointer;
  43.   CurVMode : Byte;
  44.   VideoSeg : WORD;
  45.   GlbLoop  : Word;
  46.  
  47.  
  48. { ThisIs() displays a message informing us which RAM Block is begin displayed }
  49. Procedure ThisIs(WhichPtr : String);
  50. begin
  51.   GotoXY(1,1);
  52.   Write('This is the 1st 4000 bytes of ',WhichPtr,'^.  Press any key...');
  53.     { Tell user which block of RAM we're looking at on screen }
  54.  
  55.   ReadLn;
  56.     { Wait for a key, and do a CR/LF }
  57. end;
  58.  
  59.  
  60. Function GetVideoMode : Byte;   {Inline macro, returns 7 for Mono, else Color}
  61. Inline($B4/$0F/$CD/$10);
  62.  
  63.  
  64.  { Main Body }
  65. BEGIN
  66. { Test for Monochrome or Color active monitor }
  67.   CurVMode:=GetVideoMode;
  68.   If CurVMode=7 then    { VideoMode=7  MONO }
  69.     VideoSeg:=$b000
  70.   else if CurVMode<4 then
  71.     VideoSeg:=$B800
  72.   else
  73.     Begin
  74.       WriteLn(^G);
  75.       Halt(CurVMode);
  76.     end;
  77.  
  78. { Allocate us same Heap space }
  79.   GetMem(P1,$3FFF);
  80.   GetMem(P2,$3FFF);
  81.  
  82. { Init P1^ to all 3's, then copy 1st $1000 bytes to Video RAM }
  83.   FillChar(P1^,$3FF0,#3);
  84.   ClrScr;
  85.   Move(P1^,Mem[VideoSeg:0],$1000);
  86.     { Use Turbo Move() when either Source or Dest is only an 8 bit device! }
  87.  
  88.   ThisIs('P1');  { Tell user what they're looking at }
  89.  
  90. { Init P2^ to all 2's, then copy 1st $1000 bytes to Video RAM }
  91.   FillChar(P2^,$1FF0,#2);
  92.   Move(P2^,Mem[VideoSeg:0],$1000);  { See note on Line #82 }
  93.  
  94.   ThisIs('P2');
  95.  
  96. { Now, 1st 12K of P2^ to P1^ as fast as possible!  32-bit or 16-bit}
  97. {  This is were you would insert your loop if using your own routines
  98.   to time different move variations }
  99.  
  100.   For GlbLoop:=1 to NumLoops do     { NumLoops distributed set to 1 }
  101.     Move32(P2^,P1^,$0E00);  { Move32() normally used for larger xfers }
  102.  
  103.   ClrScr;
  104.  
  105. { Display 1st 4096 bytes of P1^ on screen }
  106.   Move(P1^,Mem[VideoSeg:0],$1000);
  107.  
  108.   ThisIs('P1');
  109.  
  110.   FreeMem(P1,$3FFF);
  111.   FreeMem(P2,$3FFF);
  112.   ClrScr;
  113.   WriteLn('80386/486 detected:= ',Has386);
  114.   WriteLn('XFer method used  := ',XFerMethod[Has386]);
  115. END.
  116.